package com.fangngng.pushall.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * user
 * @author 
 */
@Data
public class User implements UserDetails, Serializable {

    private static final long serialVersionUID = 7939522100845972172L;

    public static final Integer LIFECYCLE_ENABLE = 1;

    public static final Integer LIFECYCLE_DISABLE = 0;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    private String email;

    private String name;

    private String nickName;

    private String code;

    private Integer status;

    private Date createTime;

    private Date updateTime;

    private Boolean checkStatus;

    /**
     * 1-可用，0-不可用
     */
    private Integer lifecycle;

    private String password;

    private String salt;

    private List<Role> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getUsername() {
        return name;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}